<!--
To change this template, choose Tools | Templates
and open the template in the editor.

<html>
	<script src="js/jquery-1.7.1.min.js"></script>
	<script src="js/quickforms.js"></script>
    <script type="text/javascript">
		var username ='<%= request.getUserPrincipal().getName() %>';
        setCookie('username',username,1);
        
        window.location ="Visits.html";
    </script>
</html>-->
<!DOCTYPE html> 
<html> 
	<head> 
	<title>My Resident</title> 
	<meta name="viewport" content="width=device-width, initial-scale=1"> 
	<link rel="stylesheet" href="css/login.css" />
	<script src="js/jquery-1.7.1.min.js"></script>
	<script src="js/quickforms.js"></script>
	<script type= "text/javascript">
		$(function(){
				if(getParameterByName("incorrect")== "true")
				{
						$('#loginfrm').prepend("<p style='color:red'>Incorrect username password combination</p>");
				}
		});
		function logIn()
		{
			var md5edPass = md5($('#j_password').val());
			var username = $('#j_username').val();
			getResultSet('rpp','getUserDetails','username='+username+",userpass="+md5edPass,function(data){
				if(isJSONString(data))
				{
					var json=JSON.parse(data);
					setCookie("userid",json[0].team_members_key,1);
					setCookie('username',username,1);
					window.location = 'Visits.html';
				}
				else
				{
					window.location = 'index.html?incorrect=true';
				}
			});
		}
	
	$(document).keypress(function(e) {
    if(e.which == 13) {
        logIn();
    }
});
	</script>
	<!--
        <script src="js/jquery-ui-1.10.0.custom.min.js"></script>
	<script src="js/jquery.mobile-1.1.1.min.js"></script>-->
</head> 
<body>



<div data-role="page">

	<div class ="container">	
			
			<p style="font-size:large">RPP Login</p>
			<hr />
			<p style="color:gray">Version 0.1 (build 1001)</p>
            <form id="loginfrm">
				<table border = "0" cellpadding="2"><tr>
                <td><label for="j_username">Username:</label></td>
                <td><input type="text" name="j_username" id="j_username" value="admin"  /></td>
				</tr><tr>
                <td><label for="j_password">Password:</label></td>
                <td><input type="password" name="j_password" id="j_password" value="" /></td>
				</tr><tr><td></td>
                <td><input type="button" onclick = "logIn()" value="Log In"/></td>
				</tr></table>
            </form>	
			<hr />
			<a href ="teams.html">Forgot your password?</a>
	</div>
	<div align="center">
	Copyright &copy; 2013 RPP
	</div>
	<div data-role="footer">
	   <h4></h4>
	</div>

</div><!-- /page -->

</body>
</html>